/*
 * Created on 2004/11/20
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package naru.queuelet.store;

import java.util.Properties;

import naru.queuelet.core.QueueletProperties;

/**
 * @author NARU
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class QueueStoreSql {
	private String terminal;
	private String crateSQL="CREATE TABLE ${terminal} ( " +
		"ID integer generated by default as identity (start with 1) " +
		", element OBJECT)";
	private String dropSQL="DROP TABLE ${terminal} if exists";
	private String insertSQL="INSERT INTO ${terminal} (element) VALUES (?)";
	private String deleteSQL="DELETE FROM ${terminal} where id=?";
	private String countSQL="SELECT count(*) from ${terminal}";
	private String listSQL="SELECT top ${count} id, element FROM ${terminal} order by id";
	private String checkSQL="SELECT count(*) from INFORMATION_SCHEMA.SYSTEM_TABLES where table_name='${terminal}'";
	private String shutdownSQL="SHUTDOWN ";
	
	public QueueStoreSql(String terminal,QueueletProperties properties){
		this.terminal=terminal;
		Properties runtime=new Properties();
		runtime.setProperty("terminal",terminal);
		crateSQL=properties.getProperty("store.sql.create",runtime);
		dropSQL=properties.getProperty("store.sql.drop",runtime);
		insertSQL=properties.getProperty("store.sql.insert",runtime);
		deleteSQL=properties.getProperty("store.sql.delete",runtime);
		countSQL=properties.getProperty("store.sql.count",runtime);
		listSQL=properties.getProperty("store.sql.list",runtime);
		checkSQL=properties.getProperty("store.sql.check",runtime);
		shutdownSQL=properties.getProperty("store.sql.shutdown",runtime);
	}
	
	/**
	 * @return Returns the shtdownSQL.
	 */
	public String getShutdownSQL() {
		return shutdownSQL;
	}
	/**
	 * @return Returns the checkSQL.
	 */
	public String getCheckSQL() {
		return checkSQL;
	}
	/**
	 * @return Returns the countSQL.
	 */
	public String getCountSQL() {
		return countSQL;
	}
	/**
	 * @return Returns the crateSQL.
	 */
	public String getCrateSQL() {
		return crateSQL;
	}
	/**
	 * @return Returns the deleteSQL.
	 */
	public String getDeleteSQL() {
		return deleteSQL;
	}
	/**
	 * @return Returns the dropSQL.
	 */
	public String getDropSQL() {
		return dropSQL;
	}
	/**
	 * @return Returns the insertSQL.
	 */
	public String getInsertSQL() {
		return insertSQL;
	}
	/**
	 * @return Returns the listSQL.
	 */
	public String getListSQL() {
		return listSQL;
	}
}
